package com.example.passingdatatointents;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ImageView;
import android.widget.TextView;

public class MainDetail extends Activity {
	
	private String flowerName;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main_detail);
		getActionBar().setDisplayHomeAsUpEnabled(true);
		Intent intent = getIntent();
		flowerName = intent.getStringExtra("flowerName");
		int imageRes = intent.getIntExtra("imageResource", 0);
		String instructions = intent.getStringExtra("instructions");
		TextView tv1 = (TextView) findViewById(R.id.textView1);
		tv1.setText(flowerName);
		tv1 = (TextView) findViewById(R.id.textView2);
		tv1.setText(instructions);
		ImageView image = (ImageView) findViewById(R.id.imageView1);
		image.setImageResource(imageRes);
	}
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// TODO Auto-generated method stub
		if(item.getItemId() == android.R.id.home){
			finish();
		}
		return super.onOptionsItemSelected(item);
	}
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// TODO Auto-generated method stub
		getMenuInflater().inflate(R.menu.detail, menu);
		return super.onCreateOptionsMenu(menu);
	}
	public void addToCart(MenuItem item){
		Intent intent = new Intent();
		intent.putExtra("flowerName", flowerName);
		intent.putExtra("action", "add");
		setResult(RESULT_OK, intent);
		finish();
	}
}
